#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float32.hpp"


class NodeTe2 : public rclcpp::Node
{
private:
    // 声明一个订阅者
    rclcpp::Subscription<std_msgs::msg::Float32>::SharedPtr dingyuezhe;
    //
    void sub_callback(const std_msgs::msg::Float32::SharedPtr ikun)
    {
        float b=ikun->data;
        b=b*10.0;
        RCLCPP_INFO(this->get_logger(), "ni gan ma: %f", b);
    }

public:
    NodeTe2(std::string name) : Node(name)
    {
        RCLCPP_INFO(this->get_logger(), "%s节点已经启动.", name.c_str());
        // 创建一个订阅者订阅话题
        dingyuezhe= this->create_subscription<std_msgs::msg::Float32>
            ("ikun_receive", 10, 
            std::bind(&NodeTe2::sub_callback, 
            this, std::placeholders::_1));
    }

};


int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    /*创建对应节点的共享指针对象*/
    auto node = std::make_shared<NodeTe2>("node_te2");
    /* 运行节点，并检测退出信号*/
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}